﻿<Window x:Class="Neudesic.AzureStorageExplorer.Dialogs.EditEntityDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="Edit Entity"
        Width="420" Height="360" MinHeight="120"
        HorizontalAlignment="Center" VerticalAlignment="Center"
        Icon="/Images/App.ico"
        WindowStartupLocation="CenterOwner"
        ShowInTaskbar="False" 
        >
    <Window.Resources>

        <Style x:Key="DataGridColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}">
            <Setter Property="Background" Value="#FFCDE7F4" />
            <Setter Property="Foreground" Value="#FF07034B"/>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFA1CCE0" Offset="0"/>
                        <GradientStop Color="#FFABD5EA" Offset="1.0"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>
    <Grid Margin="8" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <TextBlock Grid.Row="0"
                   Text="Entity properties:"
                   Margin="0,0,0,2"
                   />

        <ScrollViewer Name="PropertyPane" 
                      Margin="0,0,0,8"
                      Grid.Row="1" 
                      VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" 
                      HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" 
                      VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"
                      MinHeight="200"
                      Padding="0">
            <Border BorderBrush="Black" BorderThickness="1">
                <DataGrid Name="PropertyGrid"
                          AutoGenerateColumns="False"
                          Background="Transparent"
                          RowBackground="White"
                          Foreground="Black"
                          FontFamily="Calibri" FontWeight="10" GridLinesVisibility="All"
                          ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
                          HorizontalGridLinesBrush="#22000000" VerticalGridLinesBrush="#22000000"
                          HeadersVisibility="All" 
                          ItemsSource="{Binding Properties,Mode=TwoWay}"
                          CanUserAddRows="True" CanUserDeleteRows="True"
                          CanUserReorderColumns="True" CanUserResizeColumns="True"
                          CanUserResizeRows="True" CanUserSortColumns="True"
                          >
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Property" Width="Auto" Binding="{Binding PropertyName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

                            <DataGridComboBoxColumn Header="Type" Width="Auto" 
                                                    SelectedItemBinding="{Binding PropertyType,Mode=TwoWay}" 
                                                    >
                                <DataGridComboBoxColumn.ItemsSource>
                                            <col:ArrayList>
                                                <sys:String>string</sys:String>
                                                <sys:String>binary</sys:String>
                                                <sys:String>bool</sys:String>
                                                <sys:String>boolean</sys:String>
                                                <sys:String>byte</sys:String>
                                                <sys:String>datetime</sys:String>
                                                <sys:String>decimal</sys:String>
                                                <sys:String>double</sys:String>
                                                <sys:String>guid</sys:String>
                                                <sys:String>int</sys:String>
                                                <sys:String>int16</sys:String>
                                                <sys:String>int32</sys:String>
                                                <sys:String>int64</sys:String>
                                                <sys:String>sbyte</sys:String>
                                                <sys:String>single</sys:String>
                                </col:ArrayList>
                                </DataGridComboBoxColumn.ItemsSource>
                            </DataGridComboBoxColumn>

                        <DataGridTextColumn Header="Value" Width="Auto" Binding="{Binding PropertyValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                        </DataGrid.Columns>
                    </DataGrid>
            </Border>
        </ScrollViewer>

        <StackPanel Grid.Row="2" Orientation="Horizontal" >
            <Button Name="SaveEntity" 
                    Content="Update Entity" IsDefault="True"
                    Margin="0,0,4,0"
                    Height="22"
                    FontFamily="Calibri" FontSize="12"
                    Template="{DynamicResource GlassButton}" Foreground="Black"                     
                    Click="SaveEntity_Click" />
            <Button Content="Cancel" IsCancel="True" 
                    Margin="0,0,8,0"
                    Height="22"
                    FontFamily="Calibri" FontSize="12"
                    Template="{DynamicResource GlassButton}" Foreground="Black"                     
                    Click="Cancel_Click" />
        </StackPanel>
    </Grid>
</Window>
